﻿using System;
using System.Collections.Generic;
using System.Linq;
using Itenso.TimePeriod;
using LogManager.Base.Models.Projections;

namespace LogManager.Base.Data
{
    /// <summary>
    /// Interface to define how the service should return the types
    /// This provides possibilities to do these actions more performant
    /// </summary>
    public interface IEventService : IDisposable
    {
        /// <summary>
        /// Get a specified event, will be a typed event with all properties
        /// </summary>
        /// <param name="serverName">Name of the server of the log</param>
        /// <param name="logName">Name of the log</param>
        /// <param name="id">Id of the event</param>
        /// <returns></returns>
        IEvent GetEvent(string serverName, string logName, string id);

        IEnumerable<IEventImport> GetImports();
        IEnumerable<EventsPerDataProjection> GetEventsPerDate();
        IEnumerable<LevelsPerDateProjection> GetLevelsPerDate();
        IEnumerable<EventsTypesPerLogProjection> GetEventsType();
        IEnumerable<EventsPerPathProjection> GetEventsPath();

        /// <summary>
        /// Get events per log with custom lucene index
        /// </summary>
        /// <returns></returns>
        IEnumerable<EventsPerLogProjection> GetEventsPerLog();

        /// <summary>
        /// Get levels per log with custom lucene index
        /// </summary>
        /// <returns></returns>
        IEnumerable<LevelsPerLogProjection> GetLevelsPerLog();

        /// <summary>
        /// Get all users of events
        /// </summary>
        /// <returns></returns>
        IEnumerable<string> GetUsers();

        /// <summary>
        /// Get all levels of events
        /// </summary>
        /// <returns></returns>
        IEnumerable<string> GetLevels();

        /// <summary>
        /// Get events with the applied filters
        /// </summary>
        /// <param name="dateFilter">Date filter is required</param>
        /// <param name="serverName">Name of the server to filter</param>
        /// <param name="logName">Name of the log to filter</param>
        /// <returns></returns>
        IQueryable<IEvent> GetEvents(ITimePeriod dateFilter,string serverName = null,string logName = null);
    }
}